<template>
  <div class="item-card" @click="$emit('click')">
    <div class="item-image" :class="`image-${item?.image || 'default'}`">
      <div class="item-price">¥{{ item?.price }}</div>
    </div>
    <div class="item-info">
      <h3 class="item-title">{{ item?.title }}</h3>
      <p class="item-description">{{ item?.description }}</p>
      <div class="item-meta">
        <span class="item-category">{{ item?.category }}</span>
        <span class="item-date">{{ item?.publishDate }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      required: true
    }
  }
}
</script>

<style scoped>
.item-card {
  background: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  cursor: pointer;
}

.item-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.item-image {
  height: 180px;
  position: relative;
  background-size: cover;
  background-position: center;
}

.image-book {
  background-color: #e3f2fd;
  background-image: url("../images/1.jpg");
}

.image-laptop {
  background-color: #e8f5e9;
  background-image: url("../images/2.webp");
}

.image-basketball {
  background-color: #fff3e0;
  background-image: url("../images/3.webp");
}

.image-lamp {
  background-color: #fff8e1;
  background-image: url("../images/4.webp");
}

.item-price {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--secondary-color);
  color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius);
  font-weight: bold;
}

.item-info {
  padding: 15px;
}

.item-title {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--primary-color);
}

.item-description {
  color: var(--gray-color);
  font-size: 0.9rem;
  margin-bottom: 12px;
  height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--gray-color);
}

.item-category {
  background: #e9ecef;
  padding: 3px 8px;
  border-radius: 12px;
}
</style>